/****详情页服务*/
yjx.service('detailService',['$rootScope','$compile','$timeout','SharedState',function($rootScope,$compile,$timeout,SharedState) {
    return {
        killDetail: function (num) {//关闭指定层e-detail
            var d = angular.element(document.querySelector('#m-detail'));
            var ds = d.find('.e-detail');
            if (ds.length == 1) {//只有一层详情页，直接清除
                d.hide();
                d.html('')
                $timeout(function(){//更新详情层数
                    $rootScope._dCount=0;
                })
            } else if (ds.length > num) {
                ds[num].remove();
                $timeout(function(){//更新详情层数
                    $rootScope._dCount--;
                })
            }
        },
        openDetaile: function (temp) {//打开单层指定模板e-detail
            if(temp&&temp.split('/').length==1){//判断是否为路由传参（无'/'）
                switch (temp){//
                    case 'register' :
                        temp = 'components/user/agency/agency.html';
                        break;
                    default :
                        temp = 'components/user/agency/agency.html';
                        break;
                }
            }
            $rootScope._dCount = 0;//初始化详情页(子节点)数
            $timeout(function(){//更新模板
                //    console.info($scope.contrl)
                var html = '<div class="e-detail" ng-include="\''+temp+'\'"></div>';
                var detailHtml = $compile(html)($rootScope)
                angular.element(document.querySelector('#m-detail')).append(detailHtml);//后排插入
                angular.element(document.querySelector('#m-detail')).show();
                $rootScope._dCount++; //子节点数加一
            })
        }
    }
}])